﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using SpriteSheetRuntime;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace BroRPG
{
    class Constants
    {
        public static ContentManager Content;
        public static Dictionary<String,SpriteSheet> SpriteSheets = new Dictionary<string,SpriteSheet>();
        public static Dictionary<String, SpriteFont> Fonts = new Dictionary<string, SpriteFont>();
        public static SpriteBatch Spritebatch;
        public static Game Game;
        private static Effect gscaleEffect;



        private static bool alreadyBegin = false;

        public static void SpritebatchBegin(float ambiantPercent, float lightPercent, Color materialColor,Color ambiantColor, Color lightColor,  float alpha)
        {
            if (gscaleEffect == null)
                gscaleEffect = Content.Load<Effect>("hit");

            if (alpha == 0)
                alpha = 0.01f;

        

            if (!alreadyBegin)
            {
                gscaleEffect.Parameters["LightPercent"].SetValue(lightPercent);
                gscaleEffect.Parameters["AmbiantPercent"].SetValue(ambiantPercent);

                gscaleEffect.Parameters["MaterialRColor"].SetValue(materialColor.R / 255.0f);
                gscaleEffect.Parameters["MaterialGColor"].SetValue(materialColor.G / 255.0f);
                gscaleEffect.Parameters["MaterialBColor"].SetValue(materialColor.B / 255.0f);
                
                gscaleEffect.Parameters["AmbiantRColor"].SetValue(ambiantColor.R / 255.0f);
                gscaleEffect.Parameters["AmbiantGColor"].SetValue(ambiantColor.G / 255.0f);
                gscaleEffect.Parameters["AmbiantBColor"].SetValue(ambiantColor.B / 255.0f);

                gscaleEffect.Parameters["LightRColor"].SetValue(lightColor.R / 255.0f);
                gscaleEffect.Parameters["LightGColor"].SetValue(lightColor.G / 255.0f);
                gscaleEffect.Parameters["LightBColor"].SetValue(lightColor.B / 255.0f);

                gscaleEffect.Parameters["Alpha"].SetValue(alpha);

                Spritebatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, null, null, gscaleEffect);
            }
        }

        public static void SpritebatchEnd()
        {
            Spritebatch.End();
        }

    }
}
